﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OpenWaves.ActivityFeed.Web.Tests
{
    public partial class SubscriptionsList : System.Web.UI.Page
    {
        
        
        protected void Page_Load(object sender, EventArgs e)
        {
            lstMain.DataSource = SiteTopics.Topics;
            lstMain.DataBind();
        }


        protected void btnLikeLastUpdateBy(object sender, EventArgs e)
        {
            var activityFeedService = ServiceLocator.Resolve<IActivityFeedService>();
            var lastUpdate = activityFeedService.GetUpdates().FirstOrDefault();
            if (lastUpdate != null)
            {
                Button btn = sender as Button;
                lastUpdate.AddLike(btn.CommandArgument);
            }
        }

        protected void OnUnhandledUpdateContentTypeClick(object sender, EventArgs e)
        {
            var activityFeedService = ServiceLocator.Resolve<IActivityFeedService>();
            activityFeedService.PublishUpdate(new CustomUpdateContentType(), HttpContext.Current.User.Identity.Name, "web", 
                new Topic[] {Topic.FromUserId(HttpContext.Current.User.Identity.Name)}, true, Enumerable.Empty<UserGroup>());
        }
    }

    public class CustomUpdateContentType: UpdateContent
    {
        
    }
}